$(document).ready(function(){
	//头像92x112
	$(".user_photo>span>a").click(function(){
		//弹出图片上传窗口
		var obj = new Helper.Window({
			id:"upload_photo",
			title:"上传头像",
			width:520,
		    height:160,
			url:Helper.basePath+"/page/memberinfo/user/photo.jsp?photoname="+$(".user_photo>img").attr("src"),
			onSuccess:function(){
				this.close();
				window.location.reload(true);
			 }});
		obj.show();
	});
	
	$("#login_history").click(function(){
		var obj = new Helper.Window({
			id:"login_history_records",
			title:"登录历史",
			width:600,
		    height:400
			});
		obj.show();
	});
	
	var lotteryQuery = new Helper.RemoteQuery({
		renderId : "recent_lottery",
		params : {
			callurl : "/page/memberinfo/sub/recent_lottery_record.jsp",
			dataType : 1,
			currentPage:1,
			pageSize:5
		},
		url : Helper.basePath + "/member_operate/findMyLottery.htm"
	});
	/*
	var uniteQuery = new Helper.RemoteQuery({
		renderId : "unite_star",
		params : {
			callurl : "/page/memberinfo/sub/unite_star.jsp",
			dataType : 1,
			currentPage:1,
			pageSize:4
		},
		url : Helper.basePath + "/member_operate/findMyUnite.htm"
	});
	uniteQuery.send();
	*/
	lotteryQuery.send();
	
	
	
	var quickQuery = new Helper.RemoteQuery({
		url:Helper.basePath+"/main/quickLotteryIssue.htm",
		renderId:"quick_lot_data_div",
		maxCacheTimeMM:120000
	});
	
	var _fnQuickQuery = function() {
		var gameId = $("#quick_lot_ul>li[class='cur']").attr("lang");
		var backUrl = "/page/memberinfo/sub/quickLot_"+gameId+".jsp";
		quickQuery.addParameters("backurl",backUrl);
		quickQuery.addParameters("gameId",gameId);
		quickQuery.send();
	};
	
	$("#quick_lot_ul>li[name='game']").click(function(){
		var gameId = $("#quick_lot_ul>li[name='game'][class='cur']").attr("lang");
		var currGameId = $(this).attr("lang");
		if(gameId!==currGameId) {
			$("#quick_lot_ul>li[name='game']").attr("class","");
			$(this).attr("class","cur");
			_fnQuickQuery();
		}
	});
	
	
	_fnQuickQuery();
	
	/**
	 * 验证手机成功朦层
	 */
	var validMobileSucc = new Helper.Window({
		id: "validMobileSucc",
		title: "手机验证成功",
		url : Helper.basePath + "/page/memberinfo/user/sub/sub_mobile_valid_success.jsp",
		width: 460,
		height: 260,
		onSuccess: function(){
			this.close();
			location.reload();
		}
	});
	
	/**
	 * 手机验证朦层
	 */
	var validMobileInput = new Helper.Window({
		id: "validMobileInput",
		title: "手机验证",
		url : Helper.basePath + "/page/memberinfo/user/sub/sub_mobile_valid_input.jsp",
		width: 460,
		height: 340,
		onSuccess: function(){
			this.close();
			validMobileSucc.show();
		}
	});
	
	/**
	 * 手机验证
	 */
	$("#ImobileValid").click(function(){
		validMobileInput.addParameters("mobileTmp", $("#Imobile").val());
		validMobileInput.show();
	});
	
	var zhanji = new Helper.Window({
		title:"用户历史战绩",
		width:600,
		height:361,
		url:Helper.basePath+"/page/unite/standings.jsp"
	});
	
	$("#unite_star>table>tbody>tr>td>a[name='username']").live('click',function(){
		var plans = $(this).attr("lang").split(",");
		zhanji.addParameters("betCardNo",plans[0]);
		zhanji.addParameters("gameId",plans[1]);
		zhanji.addParameters("userName",$(this).text());
		zhanji.show();
	});
});
